package com.welson.restfultoolx.action;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;
import com.welson.restfultoolx.ui.ApiListToolWindow;
import org.jetbrains.annotations.NotNull;

/**
 * 显示所有API动作
 * 在Tools菜单中显示，打开API列表工具窗口
 */
public class ShowAllAPIsAction extends AnAction {
    
    @Override
    public void actionPerformed(@NotNull AnActionEvent e) {
        Project project = e.getProject();
        if (project == null || project.isDisposed()) {
            return;
        }
        
        // 创建并显示API列表工具窗口
        ApiListToolWindow toolWindow = new ApiListToolWindow(project);
        toolWindow.show();
    }
    
    @Override
    public void update(@NotNull AnActionEvent e) {
        // 只在有项目时启用此动作
        Project project = e.getProject();
        e.getPresentation().setEnabled(project != null && !project.isDisposed());
    }
}